<?php

// 保存便签内容
// GET note.set
// http://sg.io/api?note.set

namespace app\api\resource\note;
use think\Db;
use think\facade\Session;

class Set
{
    // 方法
    public $_method = ['PUT','OPTIONS'];
    // 前置
    public $_pre    = ['member'];
    // 描述
    public $_description = '保存便签内容';
    // 参数
    public $_param  = [
        'content' => '便签内容',
    ];

    public function run(&$request)
    {
        $content = $request->param('content/s','');
        $mid     = Session::get('member.id');
        $data['content']     = $content;
        $data['update_time'] = time();
        $num = Db::name('note')->where('mid',$mid)->update($data);
        return ($num >= 0) ? [201,'保存成功'] : [500,'保存失败'];
    }
}
